package sanmubird.scratch.y210914;

import lombok.*;
import lombok.experimental.Accessors;
import lombok.experimental.Tolerate;

import java.util.Comparator;
import java.util.List;


/**
 * @author sam
 * @date 2021/9/14 20:04
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
@Builder
@EqualsAndHashCode
public class Task {

    private Long taskId;

    private List<Tag> tagList;


    @Getter
    @Setter
    @ToString
    @Accessors(chain = true)
    @Builder
    public static class Tag {

        private TypeEnum type;

        /**
         * 数值越大说明 比重越高
         */
        private int order;

        @Tolerate
        public Tag() {
            // empty constructor
        }

    }

    @Tolerate
    public Task() {
        // empty constructor
    }

    public Tag getMaxOrderTag() {
        return this.getTagList().stream().max(Comparator.comparing(Tag::getOrder)).orElse(null);
    }

}
